import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { TweenLite } from "../../../../../com/greensock/TweenLite";
import { Cubic } from "../../../../../com/greensock/easing/Cubic";
import { EffectManager } from "../../../manager/EffectManager";
//class DiceBtn
    
    export  class DiceBtn /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.bmp = ObjCreate.createBitmap(ImagesConst.LGXB_Btn, 0, 0, this);
            this.buttonMode = true;
            return;
        }

        public toShow(): void
        {
            if (this.curTween) 
            {
                this.curTween.pause();
                this.curTween.kill();
            }
            this.bmp.x = 200;
            this.bmp.y = 0;
            this.bmp.alpha = 0;
            this.bmp.visible = true;
            this.curTween = TweenLite.to(this.bmp, 0.5, {"alpha": 1, "x": 10, "ease": Cubic.easeInOut, "onComplete": this.showTweenEnd});
            return;
        }

        public showAchievementEffect(arg1: Boolean): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1) 
            {
                loc1 = new Object /* flash.filters.GlowFilter */(268435302, 1, 6, 6, 4);
                loc2 = [loc1];
                EffectManager.glowFilterReg(this, loc2, 0.8, 10, 5, 0);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this);
            }
            return;
        }

        public toHide(): void
        {
            if (this.curTween) 
            {
                this.curTween.pause();
                this.curTween.kill();
            }
            var loc1=this.bmp.alpha - 0.4;
            if (loc1 < 0) 
            {
                loc1 = 0;
            }
            var loc2;
            this.mouseEnabled = loc2 = false;
            this.mouseChildren = loc2;
            this.showAchievementEffect(false);
            this.curTween = TweenLite.to(this.bmp, 0.4, {"alpha": loc1, "onComplete": this.hideTweenEnd});
            return;
        }

        /* internal  */showTweenEnd(): void
        {
            var loc1;
            this.mouseEnabled = loc1 = true;
            this.mouseChildren = loc1;
            this.showAchievementEffect(true);
            return;
        }

        /* internal  */hideTweenEnd(): void
        {
            this.bmp.alpha = 0;
            this.bmp.visible = false;
            return;
        }

        /* internal */ /* var */bmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */curTween: TweenLite;
    }
